<template>
	<view class="container">
		<view class="tab">
			<block v-for="(item,index) in tabber" :key="index">
				<text :class="['uni-flex-item', index == idx?'on':'']" @click="idx = index">{{item}}({{index == 1 ? dayCount : monthCount}})</text>
			</block>
		</view>
		<view v-show="idx == 0">
			<view class="uni-list" v-if="list.length > 0">
				<view class="list flex-row row-middle uni-list-cell-pd" v-for="(item, index) in list" :key="index">
					<view>
						<image mode="widthFix" :src="item.headImgUrl || '../../../static/images/default_avatar.png'" class="pic"></image>
					</view>
					<view>
						<view class="bold">{{item.storeName}}</view>
						<view>{{item.userName}}</view>
					</view>	
					<view class="p flex-row row-right">{{item.userPhone}}</view>
				</view>
			</view>
			<view v-else>
				<u-empty mode="favor" icon="../../../../static/images/comment.png" text="暂无记录" width="320" height="320"
					textSize="24"></u-empty>
			</view>
		</view>
	</view>
</template>


<script>
	import {
		getBindStore,
		getLocalStore
	} from "@/api/user";
	export default {
		data() {
			return {
				list: [],
				idx: 0,
				tabber: ['今日新增', '本月新增'],
				dayCount: 0,
				monthCount: 0
			}

		},
		
		onLoad() {
			
		},
		
		onShow() {
			let that = this;
			that.getLocalStore();
			that.getBindStore();
		},

		methods: {
			
			/**
			 * 获取未绑定门店
			 */
			getLocalStore() {
				let that = this;
				getLocalStore({
					userInfoId: that.$store.state.app.uid
				}).then(res => {
					that.list = res.value.list;
				}).catch(err => {
					that.$util.Tips({
						title: err
					})
				})
			},
			
			getBindStore() {
				let that = this;
				getBindStore({
					userInfoId: that.$store.state.app.uid
				}).then(res => {
						dayCount = res.value.dayCount;
						monthCount = res.value.monthCount;
				}).catch(err => {
					that.$util.Tips({
						title: err
					})
				})
			}
		}
	}
</script>

<style>
	page {
		background: #F3F3F3;
	}
	
	.container .tab {
		display: flex;
		align-items: center;
		text-align: center;
		background: #fff;
	}
	
	.container .tab text {
		padding: 20rpx 0;
		position: relative;
	}
	
	.container .tab .on {
		font-weight: bold;
		font-size: 36rpx;
		color: #06A972;
	}
	
	.container .tab .on::after {
		content: '';
		width: 72rpx;
		height: 4rpx;
		position: absolute;
		bottom: 0;
		left: 50%;
		transform: translate(-50%, 0);
		background: #06A972;
		border-radius: 2px 2px 2px 2px;
	}
	

	.container .uni-list image {
		width: 88rpx;
		height: 88rpx;
		border-radius: 50%;
		margin-right: 30rpx;
	}

	.uni-list {
		background: none;
		padding: 10rpx 20rpx;
	}

	.list {
		background: #fff;
		border-radius: 20rpx;
		margin-top: 20rpx;
	}

	.bold {
		font-weight: bold;
	}
	
	.p {
		flex: 1;
	}
</style>
